<extend name="public:base"/>

<block name="main">

    <div class="slide_main fr">
        <h1 class="frame_title mb10">账户提现</h1>

        <div class="frame_slide">

            <ul class="hd cl">
                <li
                <if condition="$Request.action eq 'index'">class="first on"
                    <else/>
                    class="first"
                </if>
                >
                <a href="{:url('user/withdraw/index')}">账户提现</a>
                </li>
                <li
                <if condition="$Request.action eq 'log'">class="on"</if>
                >
                <a href="{:url('user/withdraw/log')}">提现记录 </a>
                </li>
            </ul>

        </div>
        <div class="frame_slide_con bd">

            <!-- 提现 -->
            <div class="chargeSlide cl">
                <form action="{:url('user/withdraw/handle')}" method="post" id="form" target="_blank">

                    <table cellpadding="0" cellspacing="0" border="0" class="tableRecharge" style="margin:0 auto;">
                        <tr class="small">
                            <td style="width:100px;">账户余额：</td>
                            <td>
                                <span class="f18 af60">{$account_money|default='0.00'}</span>
                                <span class="f14 a999">元</span>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">提现金额：</td>
                            <td>
                                <input type="text" name="money" size="40" value="" maxlength="11" data-min="{$min}"
                                       data-rate="{$rate}"
                                       data-max="{$account_money|default='0.00'}" class="input_t" id="monwithdraw"
                                       placeholder="请填写提现金额"
                                       onkeyup="this.value=checkMoney(this.value);" required/>
                                <span class="pl5">元</span>
                            </td>
                        </tr>

                        <tr>
                            <td valign="top">登录密码：</td>
                            <td>
                                <input type="password" name="password" id="password" size="40" value="" class="input_t"
                                       placeholder="请填写账户登录密码" required/>
                                <span class="pl5"></span>
                            </td>
                        </tr>

                        <tr>
                            <td valign="top">提现手续费：</td>
                            <td>
                                <!--<input type="text" size="40" class="input_t" id="fee" readonly placeholder="手续费">-->
                                <span class="pl5" id="fee">0元</span>
                            </td>
                        </tr>

                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <input type="submit" value="提现" class="btn_b submitBtn"/>

                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <div class="userTips">
                                    <dl>
                                        <dt><i class="iconFont af60">&#xe643;</i><span class="af60">温馨提示</span></dt>
                                        <dd>
                                            <p>1.{$min}元起提；</p>
                                            <p>2.信用卡不得设为提现银行卡；</p>
                                            <p>3.请确保您的提现信息正确，以免影响您的到账时间；</p>
                                            <p>4.单笔提现{$rate}/笔计扣，用户注册后从未经任何一轮投资即提现，按提现金额的1.5‰计扣提现费（最低2元）。</p>
                                        </dd>
                                    </dl>
                                </div>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>

        </div>
    </div>


</block>

<block name="js">

    <script type="text/javascript" src="__JS__/checkcode.js"></script>

    <script type="text/javascript">

        $(function () {
            $('#monwithdraw').on('keyup', function () {
                $('#fee').text($(this).val() * $(this).attr('data-rate') + '元');
            });
        });

        $("#form").submit(function () {
            var self = $(this);
            var input = $("#monwithdraw");
            var money = parseFloat(input.val());
            var min = parseFloat(input.attr("data-min"));
            var max = parseFloat(input.attr("data-max"));
            var password = self.find('#password').val();

            if (password.length < 6) {
                layer.alert("请输入登录密码", {icon: 0}, function (index) {
                    layer.close(index);
                    $(input).focus();
                });
                return false;
            }

            if (money.length < 0 || isNaN(money)) {
                layer.alert("请输入提现金额", {icon: 0}, function (index) {
                    layer.close(index);
                    $(input).focus();
                });
                return false;
            }

            if (money < min) {
                layer.alert("每笔提现金额至少100元以上", {icon: 0}, function (index) {
                    layer.close(index);
                    $(input).focus();
                });
                return false;
            }
            if (money > max) {
                layer.alert("提现金额不能大于可提现金额" + max + "元", {icon: 0}, function (index) {
                    layer.close(index);
                    $(input).focus();
                });
                return false;
            }


            $.post(self.attr("action"), self.serialize(), success, "json");

            function success(data) {
                layer.closeAll();
                if (data.code == 1) {
                    layer.alert(data.msg, {icon: 1});
                    setTimeout(function () {
                        window.location.href = "{:url('user/withdraw/log')}";
                    }, 1500);
                } else {
                    layer.alert(data.msg, {icon: 2});
                    return false;
                }
            }

            return false;
        });
    </script>
</block>

